using UnityEngine;

public class SoundsManager : MonoBehaviour
{
	public UIButton musicBtnOn;

	public UIButton musicBtnOff;

	public UIButton soundBtnOn;

	public UIButton soundBtnOff;

	public UISlider sliderSound;

	public UISlider sliderMusic;

	private void OnEnable()
	{
		sliderSound.value = VolumeController.VolumeSound;
		sliderMusic.value = VolumeController.VolumeMusic;
		soundBtnOn.gameObject.SetActive(VolumeController.SoundOn);
		soundBtnOff.gameObject.SetActive(!VolumeController.SoundOn);
		musicBtnOn.gameObject.SetActive(VolumeController.MusicOn);
		musicBtnOff.gameObject.SetActive(!VolumeController.MusicOn);
	}

	public void SetVolSound()
	{
		if (!VolumeController.SoundOn)
		{
			VolumeController.SoundOn = true;
		}
		if (sliderSound.value != 0f)
		{
			VolumeController.VolumeSound = sliderSound.value;
		}
		if (sliderSound.value == 0f)
		{
			VolumeController.SoundOn = false;
			VolumeController.VolumeSound = 0f;
		}
		soundBtnOn.gameObject.SetActive(VolumeController.SoundOn);
		soundBtnOff.gameObject.SetActive(!VolumeController.SoundOn);
	}

	public void SetVolMusic()
	{
		if (!VolumeController.MusicOn)
		{
			VolumeController.MusicOn = true;
		}
		if (sliderMusic.value != 0f)
		{
			VolumeController.VolumeMusic = sliderMusic.value;
		}
		if (sliderMusic.value == 0f)
		{
			VolumeController.MusicOn = false;
			VolumeController.VolumeMusic = 0f;
		}
		musicBtnOn.gameObject.SetActive(VolumeController.MusicOn);
		musicBtnOff.gameObject.SetActive(!VolumeController.MusicOn);
	}

	public void ToggleSound()
	{
		if (VolumeController.SoundOn)
		{
			sliderSound.value = 0f;
			return;
		}
		VolumeController.SoundOn = true;
		sliderSound.value = VolumeController.VolumeSound;
	}

	public void ToggleMusic()
	{
		if (VolumeController.MusicOn)
		{
			sliderMusic.value = 0f;
			return;
		}
		VolumeController.MusicOn = true;
		sliderMusic.value = VolumeController.VolumeMusic;
	}
}
